package haw.its.a2;

import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.Scanner;

public class HC1 {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);
		System.out.print("Startwert: ");
		long seed = Long.parseLong(scan.nextLine());
		// src\haw\its\a2\Klar.txt
		System.out.print("Pfad: ");
		String path = scan.nextLine();

		LCG lcg = new LCG(214013, 13523655, 2 ^ 24, seed);

		try {
			FileInputStream fis = new FileInputStream(path);
			FileOutputStream fos = new FileOutputStream(path + "enc");

			while (fis.available() > 0) {
				fos.write((int) (fis.read() ^ (int) Double
						.doubleToRawLongBits(lcg.nextValue())));
			}
			scan.close();
			fis.close();
			fos.close();

		} catch (IOException e) {
			e.printStackTrace();
		}

	}

}
